﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace NewstorePlateformeDAO
{
    static class EntitiesHelper
    {
        public readonly static string connexionString = System.Configuration.ConfigurationManager.ConnectionStrings["Newstore_PL_GOLD_BDDEntities"].ConnectionString;

        public static void DisplayDebug(string message)
        {
            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Debug.AutoFlush = true;
            Debug.Indent();
            Debug.WriteLine("ENTITY :");
            Debug.WriteLine("Message : " + message);

            Debug.Unindent();
        }

        /// <summary>
        /// Displays the debug.
        /// </summary>
        /// <param name="origin">The origin.</param>
        /// <param name="ex">The ex.</param>
        public static void DisplayDebug(string origin, Exception ex)
        {
            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Debug.AutoFlush = true;
            Debug.Indent();
            Debug.WriteLine("ENTITY :");
            Debug.WriteLine("Origine : " + origin);
            Debug.WriteLine("Erreur : " + ex.Message);
            Exception innerException = ex.InnerException;
            while (innerException != null)
            {
                Debug.WriteLine(innerException.Message);
                innerException = innerException.InnerException;
            }

            Debug.Unindent();
        }
    }
}
